package com.bk.controller.address;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bk.entity.AddressInfo;
import com.bk.service.address.AddressService;
import com.bk.util.ReturnUtil;

@RestController /** @author czl 地址省级联动 */
public class AddressController {

	@Autowired
	private AddressService addressService;

	@GetMapping("/getAddressByLevel/{level}") /** 通过级别查询城市 */
	public ReturnUtil<AddressInfo> getAddress(@PathVariable("level") int level) {
		List<AddressInfo> addList = addressService.getAddressByLevel(level);

		return new ReturnUtil<>(200, "获取相应级别城市", addList);
	}
	@GetMapping("/getAddressByParentId/{parentId}")/**通过父类id查询子城市*/
	public ReturnUtil<AddressInfo> getAddressByParentId(@PathVariable("parentId") int parentId){
		
		List<AddressInfo> addList = addressService.getAddressByParentId(parentId);

		return new ReturnUtil<>(200, "获取相应子级别城市", addList);
	}

}
